package oa.service.impl;

import java.util.Collection;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import oa.dao.RoleDao;
import oa.domain.page.PageBean;
import oa.domain.system.Role;
import oa.service.RoleService;
import oa.util.HQLHelper;

@Service("roleService")
public class RoleServiceImpl implements RoleService {

	@Resource(name="roleDao")
	private RoleDao roleDao;
	
	@Override
	public Collection<Role> getAllRole() {
		// TODO Auto-generated method stub
		return this.roleDao.getAllEntry();
	}

	@Override
	@Transactional(readOnly=false)
	public void saveRole(Role role) {
		// TODO Auto-generated method stub
	     this.roleDao.saveEntity(role);
	}

	@Override
	public Role getRoleById(Long id) {
		// TODO Auto-generated method stub
		return this.roleDao.getEntryById(id);
	}

	@Override
	@Transactional(readOnly=false)
	public void upateRole(Role role) {
		// TODO Auto-generated method stub
		this.roleDao.updateEntry(role);
	}

	@Override
	@Transactional(readOnly=false)
	public void deleteRole(Long id) {
		// TODO Auto-generated method stub
		this.roleDao.deleteEntry(id);
	}

	@Override
	public Set<Role> getRoleByIds(String checkedStr) {
		// TODO Auto-generated method stub
		return this.roleDao.getEntryByIds(checkedStr);
	}

	@Override
	public Collection<Role> getRoleByUid(Long uid) {
		// TODO Auto-generated method stub
		return this.roleDao.getRoles(uid);
	}

	@Override
	public PageBean getPageBean(HQLHelper hh, int currentPage) {
		// TODO Auto-generated method stub
		return this.roleDao.getPageBean(hh, currentPage);
	}

}
